﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:ESRI.ArcGIS.Client.Toolkit"
    xmlns:localprimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
    xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input">
    <Style x:Key="MenuButtonStyle" TargetType="Button">
        <Setter Property="Background" Value="#FF1F3B53"/>
        <Setter Property="Foreground" Value="#FF000000"/>
        <Setter Property="Padding" Value="3"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush">
            <Setter.Value>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFA3AEB9" Offset="0"/>
                    <GradientStop Color="#FF8399A9" Offset="0.375"/>
                    <GradientStop Color="#FF718597" Offset="0.375"/>
                    <GradientStop Color="#FF617584" Offset="1"/>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Fill).(Color)" Duration="00:00:00" To="#FFB7DBE6"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value=".55"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Rectangle x:Name="BackgroundGradient" Margin="1" Fill="Transparent"/>
                        <ContentPresenter x:Name="contentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                        <Rectangle x:Name="DisabledVisualElement" Fill="#FFFFFFFF" RadiusX="3" RadiusY="3" IsHitTestVisible="false" Opacity="0"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="local:FeatureDataGrid">
        <Setter Property="RowBackground" Value="#AAEAEFF4"/>
        <Setter Property="AlternatingRowBackground" Value="#00FFFFFF"/>
        <Setter Property="Background" Value="#FFFFFFFF"/>
        <Setter Property="HeadersVisibility" Value="Column"/>
        <Setter Property="HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="SelectionMode" Value="Extended"/>
        <Setter Property="CanUserReorderColumns" Value="True"/>
        <Setter Property="CanUserResizeColumns" Value="True"/>
        <Setter Property="CanUserSortColumns" Value="True"/>
        <Setter Property="AutoGenerateColumns" Value="True"/>
        <Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected"/>
        <Setter Property="BorderBrush">
            <Setter.Value>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFA3AEB9" Offset="0"/>
                    <GradientStop Color="#FF8399A9" Offset="0.375"/>
                    <GradientStop Color="#FF718597" Offset="0.375"/>
                    <GradientStop Color="#FF617584" Offset="1"/>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="DragIndicatorStyle">
            <Setter.Value>
                <Style TargetType="ContentControl">
                    <Setter Property="Foreground" Value="#7FFFFFFF"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="ContentControl">
                                <Grid>
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="SortStates">
                                            <VisualState x:Name="Unsorted"/>
                                            <VisualState x:Name="SortAscending">
                                                <Storyboard>
                                                    <DoubleAnimation Duration="0" Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Opacity" To="1.0"/>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="SortDescending">
                                                <Storyboard>
                                                    <DoubleAnimation Duration="0" Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Opacity" To="1.0"/>
                                                    <DoubleAnimation Duration="0" Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="(RenderTransform).ScaleY" To="-.9"/>
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                    <Rectangle x:Name="BackgroundRectangle" Fill="#66808080" Stretch="Fill" Grid.ColumnSpan="2"/>
                                    <Rectangle x:Name="BackgroundGradient" Stretch="Fill" Opacity="0" Grid.ColumnSpan="2">
                                        <Rectangle.Fill>
                                            <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
                                                <GradientStop Color="#FFFFFFFF" Offset="0.015"/>
                                                <GradientStop Color="#F9FFFFFF" Offset="0.375"/>
                                                <GradientStop Color="#E5FFFFFF" Offset="0.6"/>
                                                <GradientStop Color="#C6FFFFFF" Offset="1"/>
                                            </LinearGradientBrush>
                                        </Rectangle.Fill>
                                    </Rectangle>
                                    <Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <ContentPresenter Content="{TemplateBinding Content}"/>
                                        <Path x:Name="SortIcon" Fill="#7FFFFFFF" Stretch="Uniform" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Center" Width="8" Opacity="0" RenderTransformOrigin=".5,.5" Grid.Column="1" Data="F1 M -5.215,6.099L 5.215,6.099L 0,0L -5.215,6.099 Z ">
                                            <Path.RenderTransform>
                                                <ScaleTransform ScaleX=".9" ScaleY=".9"/>
                                            </Path.RenderTransform>
                                        </Path>
                                    </Grid>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="DropLocationIndicatorStyle">
            <Setter.Value>
                <Style TargetType="ContentControl">
                    <Setter Property="Background" Value="#FF3F4346"/>
                    <Setter Property="Width" Value="2"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="ContentControl">
                                <Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="GridLinesVisibility" Value="Vertical"/>
        <Setter Property="HorizontalGridLinesBrush" Value="#FFC9CACA"/>
        <Setter Property="IsTabStop" Value="True"/>
        <Setter Property="VerticalGridLinesBrush" Value="#FFC9CACA"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:FeatureDataGrid">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity" To="1"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2">
                            <Grid x:Name="Root" Background="{TemplateBinding Background}">
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition Height="24"/>
                                </Grid.RowDefinitions>
                                <Grid>
                                    <Grid.Resources>
                                        <ControlTemplate x:Key="TopLeftHeaderTemplate" TargetType="localprimitives:DataGridColumnHeader">
                                            <Grid x:Name="Root">
                                                <Grid.RowDefinitions>
                                                    <RowDefinition/>
                                                    <RowDefinition/>
                                                    <RowDefinition Height="Auto"/>
                                                </Grid.RowDefinitions>
                                                <Border Grid.RowSpan="2" Background="#FF1F3B53" BorderBrush="#FFC9CACA" BorderThickness="0,0,1,0">
                                                    <Rectangle Stretch="Fill" StrokeThickness="1">
                                                        <Rectangle.Fill>
                                                            <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
                                                                <GradientStop Color="#FCFFFFFF" Offset="0.015"/>
                                                                <GradientStop Color="#F7FFFFFF" Offset="0.375"/>
                                                                <GradientStop Color="#E5FFFFFF" Offset="0.6"/>
                                                                <GradientStop Color="#D1FFFFFF" Offset="1"/>
                                                            </LinearGradientBrush>
                                                        </Rectangle.Fill>
                                                    </Rectangle>
                                                </Border>
                                                <Rectangle Fill="#FFDBDCDC" StrokeThickness="1" Height="1" VerticalAlignment="Bottom" Width="Auto" Grid.RowSpan="2"/>
                                            </Grid>
                                        </ControlTemplate>
                                        <ControlTemplate x:Key="TopRightHeaderTemplate" TargetType="localprimitives:DataGridColumnHeader">
                                            <Grid x:Name="RootElement">
                                                <Grid.RowDefinitions>
                                                    <RowDefinition/>
                                                    <RowDefinition/>
                                                    <RowDefinition Height="Auto"/>
                                                </Grid.RowDefinitions>
                                                <Border Grid.RowSpan="2" Background="#FF1F3B53" BorderBrush="#FFC9CACA" BorderThickness="1,0,0,0">
                                                    <Rectangle Stretch="Fill">
                                                        <Rectangle.Fill>
                                                            <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
                                                                <GradientStop Color="#FCFFFFFF" Offset="0.015"/>
                                                                <GradientStop Color="#F7FFFFFF" Offset="0.375"/>
                                                                <GradientStop Color="#E5FFFFFF" Offset="0.6"/>
                                                                <GradientStop Color="#D1FFFFFF" Offset="1"/>
                                                            </LinearGradientBrush>
                                                        </Rectangle.Fill>
                                                    </Rectangle>
                                                </Border>
                                            </Grid>
                                        </ControlTemplate>
                                    </Grid.Resources>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <localprimitives:DataGridColumnHeader x:Name="TopLeftCornerHeader" Template="{StaticResource TopLeftHeaderTemplate}" Width="22"/>
                                    <localprimitives:DataGridColumnHeadersPresenter x:Name="ColumnHeadersPresenter" Grid.Column="1"/>
                                    <localprimitives:DataGridColumnHeader x:Name="TopRightCornerHeader" Template="{StaticResource TopRightHeaderTemplate}" Grid.Column="2"/>
                                    <Rectangle x:Name="ColumnHeadersAndRowsSeparator" Fill="#FFC9CACA" StrokeThickness="1" Height="1" VerticalAlignment="Bottom" Width="Auto" Grid.ColumnSpan="3"/>
                                    <localprimitives:DataGridRowsPresenter x:Name="RowsPresenter" Grid.ColumnSpan="2" Grid.Row="1"/>
                                    <Rectangle x:Name="BottomRightCorner" Fill="#FFE9EEF4" Grid.Column="2" Grid.Row="2"/>
                                    <Rectangle x:Name="BottomLeftCorner" Fill="#FFE9EEF4" Grid.ColumnSpan="2" Grid.Row="2"/>
                                    <ScrollBar x:Name="VerticalScrollbar" Margin="0,-1,-1,-1" Width="18" Grid.Column="2" Grid.Row="1" Orientation="Vertical"/>
                                    <Grid Grid.Column="1" Grid.Row="2">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition/>
                                        </Grid.ColumnDefinitions>
                                        <Rectangle x:Name="FrozenColumnScrollBarSpacer"/>
                                        <ScrollBar x:Name="HorizontalScrollbar" Height="18" Margin="-1,0,-1,-1" Grid.Column="1" Orientation="Horizontal"/>
                                    </Grid>
                                    <dataInput:ValidationSummary x:Name="ValidationSummary" MaxHeight="90" Grid.ColumnSpan="3" Grid.Row="3" Filter="ObjectErrors"/>
                                </Grid>
                                <!-- StatusBar -->
                                <StackPanel Orientation="Horizontal" Margin="0,2,0,0" Grid.Row="1">
                                    <!-- Record Navigator -->
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="Record:" VerticalAlignment="Center" Margin="1,0,3,0"/>
                                        <Button x:Name="MoveFirstButton" Content="&lt;&lt;" Cursor="Hand" ToolTipService.ToolTip="Move First"/>
                                        <Button x:Name="MovePreviousButton" Content="&lt;" Cursor="Hand" ToolTipService.ToolTip="Move Previous"/>
                                        <Border VerticalAlignment="Center" BorderThickness="0.5" BorderBrush="Gray" >
                                            <TextBox x:Name="CurrentRecordNumberTextBox" Text="0" TextAlignment="Right" Width="40"/>
                                        </Border>
                                        <Button x:Name="MoveNextButton" Content="&gt;" Cursor="Hand" ToolTipService.ToolTip="Move Next"/>
                                        <Button x:Name="MoveLastButton" Content="&gt;&gt;" Cursor="Hand" ToolTipService.ToolTip="Move Last"/>
                                    </StackPanel>
                                    <!-- TextBlock showing number of selected rows and total records -->
                                    <TextBlock x:Name="NumberOfRecordsTextBlock" Text="Records ({0} out of {1} Selected)" VerticalAlignment="Center" Margin="3,0,0,0"/>
                                    <!-- Options -->
                                    <StackPanel Orientation="Horizontal">
                                        <Grid Margin="5,0,0,0">
                                            <Button x:Name="OptionsButton" Content=" Options... " />
                                            <Popup x:Name="PopupMenu" IsOpen="False">
                                                <Border BorderThickness="1" CornerRadius="1.5" 
                                                    BorderBrush="{TemplateBinding BorderBrush}"
                                                    Background="{TemplateBinding Background}">
                                                    <StackPanel>
                                                        <Button x:Name="ClearSelectionMenuButton" Margin="5,5,5,0" Style="{StaticResource MenuButtonStyle}">
                                                            <Button.Content>
                                                                <TextBlock Text="Clear Selection" VerticalAlignment="Center" Margin="5"/>
                                                            </Button.Content>
                                                        </Button>
                                                        <Button x:Name="SwitchSelectionMenuButton" Margin="5,0" Style="{StaticResource MenuButtonStyle}">
                                                            <Button.Content>
                                                                <TextBlock Text="Switch Selection" VerticalAlignment="Center" Margin="5"/>
                                                            </Button.Content>
                                                        </Button>
                                                        <Button x:Name="SelectAllMenuButton" Margin="5,0" Style="{StaticResource MenuButtonStyle}">
                                                            <Button.Content>
                                                                <TextBlock Text="Select All" VerticalAlignment="Center" Margin="5"/>
                                                            </Button.Content>
                                                        </Button>
                                                        <Button x:Name="ZoomToSelectionMenuButton" Margin="5,0" Style="{StaticResource MenuButtonStyle}">
                                                            <Button.Content>
                                                                <TextBlock Text="Zoom To Selection" VerticalAlignment="Center" Margin="5"/>
                                                            </Button.Content>
                                                        </Button>
                                                        <Button x:Name="DeleteSelectedRowsMenuButton" Margin="5,0" Style="{StaticResource MenuButtonStyle}">
                                                            <Button.Content>
                                                                <TextBlock Text="Remove Selected Row(s)" VerticalAlignment="Center" Margin="5"/>
                                                            </Button.Content>
                                                        </Button>
                                                        <Line X1="10" Y1="2" X2="157" Y2="2" Stroke="Black" StrokeThickness="0.2"/>
                                                        <CheckBox x:Name="AutoChangeMapExtentCheckBox" Content="Auto Zoom to Selected" Margin="10,5"/>
                                                    </StackPanel>
                                                </Border>
                                            </Popup>
                                        </Grid>
                                        <Button x:Name="SubmitChangesMenuButton" Margin="5,0" Style="{StaticResource MenuButtonStyle}">
                                            <Button.Content>
                                                <TextBlock Text="Commit" VerticalAlignment="Center" Margin="5"/>
                                            </Button.Content>
                                        </Button>
                                    </StackPanel>
                                </StackPanel>
                            </Grid>
                        </Border>
                        <Border x:Name="DisabledVisualElement" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" IsHitTestVisible="False" Opacity="0" Background="#8CFFFFFF" CornerRadius="2"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>